Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call support #560

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Call support #560

wants to merge 1 commit into from

Conversation

arugaz
Copy link
Contributor

@arugaz arugaz commented Mar 28, 2024

No description provided.

@arugaz
Copy link
Contributor Author

arugaz commented Mar 28, 2024

yes, need to test again havent commit yet

Copy link

@ahmedRSA ahmedRSA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tested call reject and this is working
thank you for contribution

@gamersindo1223
Copy link

I've found a way to offer a call on dm

func (cli *Client) OfferCall(callTo types.JID, video bool) error {
	clientID := cli.getOwnJID()
	if clientID.IsEmpty() {
		return ErrNotLoggedIn
	}
	var offerLen uint8 = 6
	if video {
		offerLen++
	}
	callID := strings.ToUpper(hex.EncodeToString(random.Bytes(16)))
	plaintext, dsmPlaintext, err := marshalMessage(callTo, &waProto.Message{Call: &waProto.Call{CallKey: random.Bytes(32)}})
	if err != nil {
		return fmt.Errorf("failed to marshal call: %w", err)
	}
	destinationNode, includeIdentity := cli.encryptMessageForDevices(context.TODO(), []types.JID{clientID, callTo}, clientID, callID, plaintext, dsmPlaintext, nil)
	if includeIdentity {
		destinationNode = append(destinationNode, cli.makeDeviceIdentityNode())
	}
	offerContent := make([]waBinary.Node, 0, offerLen)
	offerContent = append(offerContent,
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "16000"}},
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "8000"}},
	)
	if video {
		offerContent = append(offerContent,
			waBinary.Node{Tag: "video", Attrs: waBinary.Attrs{"orientation": "0", "screen_width": "1080", "screen_height": "2340", "device_orientation": "0", "enc": "vp8", "dec": "vp8"}},
		)
	}
	offerContent = append(offerContent,
		waBinary.Node{Tag: "capability", Attrs: waBinary.Attrs{"ver": "1"}, Content: []byte{1, 4, 255, 131, 207, 4}},
		waBinary.Node{Tag: "destination", Content: destinationNode},
		waBinary.Node{Tag: "encopt", Attrs: waBinary.Attrs{"keygen": "2"}},
		waBinary.Node{Tag: "net", Attrs: waBinary.Attrs{"medium": "3"}},
	)
	return cli.sendNode(waBinary.Node{
		Tag:   "call",
		Attrs: waBinary.Attrs{"id": cli.GenerateMessageID(), "to": callTo},
		Content: []waBinary.Node{{
			Tag:     "offer",
			Attrs:   waBinary.Attrs{"call-id": callID, "call-creator": clientID},
			Content: offerContent,
		}},
	})
}```

@arugaz
Copy link
Contributor Author

arugaz commented Mar 30, 2024

yeah, thats what was done 4 months ago, im still looking for group call

@ahmedRSA
Copy link

ahmedRSA commented Apr 1, 2024

I've found a way to offer a call on dm

func (cli *Client) OfferCall(callTo types.JID, video bool) error {
	clientID := cli.getOwnJID()
	if clientID.IsEmpty() {
		return ErrNotLoggedIn
	}
	var offerLen uint8 = 6
	if video {
		offerLen++
	}
	callID := strings.ToUpper(hex.EncodeToString(random.Bytes(16)))
	plaintext, dsmPlaintext, err := marshalMessage(callTo, &waProto.Message{Call: &waProto.Call{CallKey: random.Bytes(32)}})
	if err != nil {
		return fmt.Errorf("failed to marshal call: %w", err)
	}
	destinationNode, includeIdentity := cli.encryptMessageForDevices(context.TODO(), []types.JID{clientID, callTo}, clientID, callID, plaintext, dsmPlaintext, nil)
	if includeIdentity {
		destinationNode = append(destinationNode, cli.makeDeviceIdentityNode())
	}
	offerContent := make([]waBinary.Node, 0, offerLen)
	offerContent = append(offerContent,
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "16000"}},
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "8000"}},
	)
	if video {
		offerContent = append(offerContent,
			waBinary.Node{Tag: "video", Attrs: waBinary.Attrs{"orientation": "0", "screen_width": "1080", "screen_height": "2340", "device_orientation": "0", "enc": "vp8", "dec": "vp8"}},
		)
	}
	offerContent = append(offerContent,
		waBinary.Node{Tag: "capability", Attrs: waBinary.Attrs{"ver": "1"}, Content: []byte{1, 4, 255, 131, 207, 4}},
		waBinary.Node{Tag: "destination", Content: destinationNode},
		waBinary.Node{Tag: "encopt", Attrs: waBinary.Attrs{"keygen": "2"}},
		waBinary.Node{Tag: "net", Attrs: waBinary.Attrs{"medium": "3"}},
	)
	return cli.sendNode(waBinary.Node{
		Tag:   "call",
		Attrs: waBinary.Attrs{"id": cli.GenerateMessageID(), "to": callTo},
		Content: []waBinary.Node{{
			Tag:     "offer",
			Attrs:   waBinary.Attrs{"call-id": callID, "call-creator": clientID},
			Content: offerContent,
		}},
	})
}```

hi is this possible to send call for only like 5 second
or X second 1, 2second ?

@gamersindo1223
Copy link

no Idea

@ahmedRSA
Copy link

ahmedRSA commented May 1, 2024

this stop working for some reason anyones having asame problem ?

@PurpShell
Copy link
Contributor

change commit name to feature: call rejection function

@ahmedRSA
Copy link

ahmedRSA commented Aug 6, 2024

will this merge ?

@mateusfmello
Copy link

change commit name to feature: call rejection function

@PurpShell @tulir

If I change the title of the PR, will you merge the feature?

I need this implementation and if @arugaz doesn't update the title, I'll implement it myself with a new title to merge into the project.

Copy link

@mateusfmello mateusfmello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented the modifications and it works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants